package ui;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;
import javax.swing.event.*;

public class Welcome extends JPanel {

	private JLabel atmWelcome;
	private JTextField insertCard;


	public Welcome() {
		setLayout(null);
		atmWelcome("Welcome to E-Bank's ATM in Esbjerg Lufthavn");
		insertCardField("Please insert your card");
		add(atmWelcome);



	}

	public void addActionListener(ActionListener l) {
		insertCard.addActionListener(l);
	}

	// Removed the old atmWelcome away from the constructor and designed its own function
	private void atmWelcome(String text){
		atmWelcome = new JLabel(text);
		atmWelcome.setHorizontalAlignment(SwingConstants.LEFT);
		atmWelcome.setFont(new Font("TIMES NEW ROMAN", Font.BOLD, 14));
		atmWelcome.setBounds(68, 42, 304, 22);
		atmWelcome.setFocusable(true); // To prevent the textfield starts with being focused

	}



	// Removed the old insertCard away from the constructor and designed its own function
	private void insertCardField (String textField){
		insertCard = new JTextField(textField);
		insertCard.setFont(new Font("TIMES NEW ROMAN", Font.PLAIN, 16));
		insertCard.setBounds(100, 100, 226, 22);


		insertCard.addActionListener(
				new ActionListener(){
					public void actionPerformed(ActionEvent event){	
						// Needs to validate the creditcard infomation here.

					}
				}	
				);
		add(insertCard, BorderLayout.NORTH);

	}
}
